import BNode from "./base/BNode";
var JS = cc.js;

export default class BTreeTools {

    private static _instance: BTreeTools;
    public static get instance(): BTreeTools {
        if (!BTreeTools._instance) {
            BTreeTools._instance = new BTreeTools();
        }
        return BTreeTools._instance;
    }

    public getNewBNode(bNodeClassName:string):BNode{
        if(bNodeClassName == "Root"){
            bNodeClassName = "BNodeSequence";
        }
        let Constructor:any = JS.getClassByName(bNodeClassName);
        if(Constructor){
            return new Constructor();
        }else{
            cc.error("行为树节点代码没有添加标签：" + bNodeClassName);
            return new BNode();
        }
    }
}
